package fr.cephb.joperon.tool;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

import fr.cephb.joperon.webservice.OperonException_Exception;
import fr.cephb.joperon.webservice.OperonWebService;
import fr.cephb.joperon.webservice.Operon;
import fr.cephb.joperon.webservice.SnpIds;
import fr.cephb.joperon.webservice.Fid;
import fr.cephb.joperon.webservice.SnpMap;

public class SnpInfo
	{
	private Operon operon;
	
	public SnpInfo()
		{
		OperonWebService operonwebservice= new OperonWebService();
		this.operon=operonwebservice.getOperonPort();
		}

	public void run(BufferedReader in)
	throws IOException,OperonException_Exception
	{
	String line;
	int nLine=0;
	
	 
	while((line=in.readLine())!=null)
		{
		if(line.trim().length()==0 || line.startsWith("#")) continue;
		System.err.println(line);
		List<SnpIds> snpids= operon.getSnpIdFromString(1,line);
		if(snpids.isEmpty())
			{
			System.err.println("Not Found");
			}
		
		for(SnpIds snpid:snpids)
			{
			System.err.println(snpid);
			Fid fid=snpid.getFid();
			System.err.println(fid);
			SnpMap map= operon.getSnpMapFromFid(1,fid.toString());
			System.err.println(map);
			
			
			
		
			}
		
		if(nLine++==3) return;
		}
	}

public static void main(String[] args)
	{
	
	try {
		
		SnpInfo app=new SnpInfo();
		File file= new File("/export/users/home/heath/chr15_mks.txt");
		BufferedReader r= new BufferedReader(new FileReader(file));
		app.run(r);
		r.close();
		} 
	catch (Exception e)
		{
		e.printStackTrace();
		}
	finally
		{
		
		}
	}
}
